import {defineStore} from "pinia";
import getCancel from '@/assets/image/get_fail.png'
import getUnpaid from '@/assets/image/get_ing.png'
import getSuccess from '@/assets/image/get_success.png'
import getWaiting from '@/assets/image/get_waiting.png'

const useState = defineStore('UseState', {
    state: () => {
        return {
            payState: {
                '0': {payName: '未支付', img: getSuccess},
                '1': {payName: '支付成功', img: getSuccess},
                2: {payName: '已取消'},
                3: {payName: '支付失败'}
            },
            getState: {
                0: {payName: '未领取', img: getSuccess},
                1: {payName: '领取成功', img: getSuccess},
            },
            patName: '',
            stateImage: ''
        }
    },
    actions: {
        handleState(data) {
            console.log(data, 26)
            let a = {};
            if (data.obtain_style === 1) {
                //    免费领取
                a = {
                    state_desc: '领取成功',
                    img: getSuccess,
                    color: 0,
                    btnState: 2,
                    imageWidth: 'get_success'
                }
            } else {
                let arr = {
                    '0_0': {
                        state_desc: '待支付',
                        img: getUnpaid,
                        color: 0,
                        btnState: 1,
                        imageWidth: "get_ing"
                    },
                    '1_0': {
                        state_desc: '待发放',
                        img: getWaiting,
                        color: 0,
                        btnState: 3,
                        imageWidth: "get_waiting"
                    },
                    '1_1': {
                        state_desc: '领取成功',
                        img: getSuccess,
                        color: 0,
                        btnState: 2,
                        imageWidth: 'get_success'
                    },
                    '2_0': {
                        state_desc: '已取消',
                        img: getCancel,
                        color: 1,
                        btnState: 4,
                        imageWidth: "get_fail"
                    },
                    '3_0': {
                        state_desc: '处理中',
                        img: getUnpaid,
                        color: 0,
                        btnState: 4,
                        imageWidth: "get_ing"
                    }
                };
                //    支付领取
                a = arr[`${data.pay_status}_${data.obtain_status}`];
            }
            return a;
        }
    },
    getters: {}
})
export default useState
